#include "iobot.h"

void iobot_put_hex(iobot_t *bot, unsigned int num)
{
	unsigned int tmp;

   iobot_put_string(bot,"0x");

   char noZeroes = 1;

   int i;
   for (i = 28; i > 0; i -= 4)
   {
       tmp = (num >> i) & 0xF;
       if (tmp == 0 && noZeroes != 0)
       {
           continue;
       }
    
       if (tmp >= 0xA)
       {
           noZeroes = 0;
           iobot_put_char(bot,tmp-0xA+'a' );
       }
       else
       {
           noZeroes = 0;
				iobot_put_char(bot, tmp+'0' );
       }
   }
  
   tmp = num & 0xF;
   if (tmp >= 0xA)
   {
       iobot_put_char(bot, tmp-0xA+'a');
   }
   else
   {
       iobot_put_char(bot, tmp+'0');
   }
}
